@echo off
set NAME=task
set PORT=2030
set REMOTE_PORT=30023
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%PORT%"') do (
    taskkill /F /PID %%a
    goto GET_INI
)
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%REMOTE_PORT%"') do (
    taskkill /F /PID %%a
    goto GET_INI
)
:GET_INI
TITLE %NAME%-%PORT%-%REMOTE_PORT%
java -Djava.rmi.server.hostname=127.0.0.1 ^
-Dcom.sun.management.jmxremote.port=%REMOTE_PORT% ^
-Dcom.sun.management.jmxremote=true ^
-Dcom.sun.management.jmxremote.ssl=false ^
-Dcom.sun.management.jmxremote.authenticate=false ^
-jar app\%NAME%.jar ^
--server.port=%PORT%
